// JavaScript Document
var Sys = {
	of : function(o){return typeof(o);},D : {},Layui : {},
	submit : function(o){
		if(typeof(o)!='object') o = $(":submit");
		o.attr('disabled','disabled');return true;
	},
	rule : function(method,a){
		switch(method){
			case '*':var r = /[\w\W]+/;break;
			case 'uname':case 'username':var r = /^([a-zA-Z0-9]|[._-]){4,25}$/;break;
            case 'pwd':case 'password':var r = /^([a-zA-Z0-9]|[._-~!@#$%^&*]){6,30}$/;break;
			case 'email':if (a == '' || a.length <6 || a.length >100) return false;var r = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;break;
			case 'key':var r = /^([a-zA-Z0-9]|[._-]){2,32}$/;break;
			case 'mobile':var r = /^1[3-9]{1}[\d]{9}$/;break;
            case 'phone':return (/^1[3-9]{1}[\d]{9}$/.test(a) || /^0[0-9]{2,3}(-)?[0-9]{7,8}$/.test(a));break;
			case 'datetime':
				var d = new Date(Date.parse(a.toString().replace(/-/g, "/")));//"2005-12-15 09:41:30"
				return /^[0-9]*[1-9][0-9]*$/.test(d.getFullYear());		
			break;case 'int':var r = /^-?\d+$/;break;//正-负整数+0
			case 'intp':var r = /^[0-9]*[1-9][0-9]*$/;break;//正整数
			case 'intps':var r = /^\d+$/;break;//正整数+0
			case 'intn':var r = /^-[0-9]*[1-9][0-9]*$/;break;//负整数
			case 'intns':var r = /^((-\d+)|(0+))$/;break;//负整数+0
			case 'dbl':case 'float':var r = /^(-?\d+)(\.\d+)?$/;break;//浮点数
			case 'dblp':var r = /^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$/;break;//正浮点数
			case 'dblps':var r = /^\d+(\.\d+)?$/;break;//正浮点数 + 0
			case 'dbln':var r = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/;break;//负浮点数
			case 'dbls':var r = /^((-\d+(\.\d+)?)|(0+(\.0+)?))$/;break;//负浮点数 + 0
			case 'boolean':var r = /^[0-1]{1}$/;break;//0|1 布尔值
			case 'booleans':var r = /^[1-2]{1}$/;break;//1|2 布尔值
			case 'numeric':var r = /^[0-9]*$/;break;
            case 'money':var r = /^([1-9][\d]{0,9}|0)(\.[\d]{1,2})?$/;break;
            case 'name':var r = /^[0-9a-zA-Z\u4e00-\u9fa5_-]+$/;break;
			default:var r = /^[+\-]?\d+(\.\d+)?$/;break;
		}
		return r.test(a);
	},
	Storage : {
		save : function(name,data){
			if(Sys.ie){
				if(data.length < 54889) {
					with(document.documentElement){setAttribute("value",data);save('Dv__'+name);}
				}
			} else if(window.localStorage){
				localStorage.setItem('Dv__'+name, data);
			} else if(window.sessionStorage){
				sessionStorage.setItem('Dv__'+name, data);
			}
		},
		load : function(name){
			if(Sys.ie){
				with(document.documentElement){load('Dv__' + name);return getAttribute("value");}
			} else if(window.localStorage){
				return localStorage.getItem('Dv__'+name);
			} else if(window.sessionStorage){
				return sessionStorage.getItem('Dv__'+name);
			}
		},
		del : function(name){
			if(Sys.ie){
				with(document.documentElement){removeAttribute('value');save('Dv__'+name);}
			} else if(window.localStorage){
				localStorage.removeItem('Dv__'+name);
			} else if(window.sessionStorage){
				sessionStorage.removeItem('Dv__'+name);
			}
			return true;
		}
	},
    Favorite : function(){
        if(Sys.ie){
            window.external.addFavorite(window.location, document.title);
        } else if (window.sidebar) {
            window.sidebar.addPanel(document.title, window.location, "");
        } else {
            alert('您可以尝试通过快捷键ctrl + D 加入到收藏夹~');
        }
    }
}


var ua = navigator.userAgent.toLowerCase();
var s;
(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
if(Sys.ie) document.documentElement.addBehavior("#default#userdata");
//try{$.fn.combobox.defaults.editable = false;$.fn.datebox.defaults.editable = false;}catch(e){}

$(document).ready(function(){
	try{Sys.EasyUI.resize();}catch(e){};
	$(document).on("click",'a[data-key="addFavorite"]',function(){
        Sys.Favorite();
    });
});